package com.heima.wemedia;

import com.heima.file.service.FileStorageService;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

@SpringBootTest(classes = WemediaApplication.class)
@RunWith(SpringRunner.class)
public class OssUpload {
    @Autowired
    FileStorageService fileStorageService;
    @Value("${file.oss.prefix}")
    String prefix;
    @Value("${file.oss.web-site}")
    String webSite;
    @Test
    public void UploadTest() throws FileNotFoundException {
        FileInputStream fileInputStream = new FileInputStream("D:\\img\\m.jpg");

        //文件在oss中的完整的路径
        String store = fileStorageService.store("prefix", "m.jpg", fileInputStream);
        System.out.println(webSite + store);
    }
}
